package com.tianqu.tms.www.common.controller;

import java.util.ArrayList;
import java.util.List;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.www.common.action.MenuAction;

/**
 * 
 * @author liugang
 *
 */
public class MenuController extends TmsController {
	
	/**
	 * 
	 */
	private Logger logger = Logger.getLogger(MenuController.class);
	/*
	 * (non-Javadoc)
	 * @see com.ibm.jp.ams.iris.controller.IrisController#execute(com.ibm.jp.ams.iris.controller.UserContext)
	 */
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		
		TxController txController = getTxController();	
		//添加事务提交异常捕获
		try {
			txController.begin();
			
//			IrisInfoMessage message= IrisInfoMessage.getInstance();
//			
//			message.init();		
			List messageList = new ArrayList();
//			messageList =message.getMsgList(uc.getUserProfile().getPrimaryCustomer(),
//					uc.getUserProfile().getPrimaryBA(), uc.getUserProfile().getLocallangCode());
			txController.commit();
			
			uc.setAttribute(MenuAction.TMSINFO_MESSAGE, messageList);
		} catch (Exception e) {
			try {
				txController.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR,e1);
			}
			//系统异常
			if(e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR,e);
		}		
		logger.debug(this.getClass().getName() + "#execute was completed.");
	}

}

